#!/bin/bash

# 定义变量方便修改
table_db=cy_database 
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`  
fi 

sql="
with
tmp_college_graduate  as(
	select
		id,
		name,
		sex,
		birthday,
		nation,
		idcard,
		census_register_area as census_register_area_code,
		census_type,
		census_register_date,
		area_code,
		phone,
		education,
		school,
		edu_time,
		graduation,
		home_address,
		enterprise_recruitment,
		startup_code,
		personal_state,
		work_whereabouts,
		company_work,
		autonomy_work,
		special_position_work,
		unemploy_type,
		now_work_company,
		work_other,
		keep_study,
		register_time,
		contact_qq,
		contact_wei,
		semester_census_address,
		qcellcore,
		hard_situation,
		other_hard_situation,
		archives_code,
		remark,
		update_time,
		census_register,
		colleges_type,
		archives_unit,
		is_internship_activity,
		work_collective_type,
		is_local,
		is_chuangye,
		card_photo_obverse,
		card_photo_back,
		education_photo,
		report_photo,
		train_type,
		now_industry_code,
		working_area
		
	from cy_database.dwd_college_graduate cg
	where cg.dt='2020-06-17' and cg.id is not null

)

insert overwrite table cy_database.dws_college_graduate_output  partition(dt='2020-06-17')
	select
		id,
		name,
		sex,
		birthday,
		nation,
		idcard,
		census_register_area_code,
		census_type,
		census_register_date,
		area_code,
		phone,
		education,
		school,
		edu_time,
		graduation,
		home_address,
		enterprise_recruitment,
		startup_code,
		personal_state,
		work_whereabouts,
		company_work,
		autonomy_work,
		special_position_work,
		unemploy_type,
		now_work_company,
		work_other,
		keep_study,
		register_time,
		contact_qq,
		contact_wei,
		semester_census_address,
		qcellcore,
		hard_situation,
		other_hard_situation,
		archives_code,
		remark,
		update_time,
		census_register,
		colleges_type,
		archives_unit,
		is_internship_activity,
		work_collective_type,
		is_local,
		is_chuangye,
		card_photo_obverse,
		card_photo_back,
		education_photo,
		report_photo,
		train_type,
		now_industry_code,
		working_area
	from tmp_college_graduate

;



"
$hive -e "$sql"